package com.ruoyi.safe.controller.api;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.safe.domain.vo.ListRequestVo;
import com.ruoyi.safe.service.IBizExcludePlanTaskService;
import com.ruoyi.safe.service.IBizExtensionRequestsService;
import com.ruoyi.safe.service.IBizProjectCheckRecordService;
import com.ruoyi.safe.service.IBizProjectCheckService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 手机端-待办接口
 */
@Slf4j
@RestController
@RequestMapping("/api/todo")
public class ToDoController {
    @Autowired
    private IBizProjectCheckService bizProjectCheckService;
    @Autowired
    private IBizExcludePlanTaskService bizExcludePlanTaskService;
    @Autowired
    private IBizProjectCheckRecordService bizProjectCheckRecordService;
    @Autowired
    private IBizExtensionRequestsService bizExtensionRequestsService;

    /**
     * 获取手机端全部待办
     *
     * @param listRequestVo 查询参数
     * @return 结果
     */
    @PostMapping("/all")
    public AjaxResult appLogin(@RequestBody ListRequestVo listRequestVo) {
        AjaxResult ajax = AjaxResult.success();
        int projectCheckCount = bizProjectCheckService.selectCount(listRequestVo);
        int planTaskCount = bizExcludePlanTaskService.selectBizExcludePlanTaskCount(listRequestVo);
        int reviewCount = bizProjectCheckRecordService.selectBizProjectCheckRecordCount(listRequestVo);
        int reformCount = bizProjectCheckRecordService.getReformCount(listRequestVo);
        int delayCount = bizExtensionRequestsService.selectBizExtensionRequestsCount(listRequestVo);
        Map<String, Object> map = new HashMap<>();
        // 项目检查
        map.put("projectCheckCount", projectCheckCount);
        // 隐患排查
        map.put("planTaskCount", planTaskCount);
        // 隐患复查
        map.put("reviewCount", reviewCount);
        // 隐患整改
        map.put("reformCount", reformCount);
        // 延期待审
        map.put("delayCount", delayCount);
        // 企业自检
        map.put("enterpriseCount", 0);
        ajax.put(AjaxResult.DATA_TAG, map);
        return ajax;
    }
}
